package com.seeyou.lake.viewmodel

import androidx.lifecycle.MutableLiveData
import com.seeyou.lake.base.myBaseViewModel
import com.seeyou.lake.bean.ArticleBean
import com.seeyou.lake.bean.UserBean
import com.seeyou.lake.net.BaseResult

class MainViewModel:myBaseViewModel() {
    val secretStatusResponse by lazy { MutableLiveData<BaseResult<Int>>() }
    val setSecretResponse by lazy { MutableLiveData<BaseResult<UserBean>>() }
    val secretArticleResponse by lazy { MutableLiveData<BaseResult<List<ArticleBean>>>() }
    val normalArticleResponse by lazy { MutableLiveData<BaseResult<List<ArticleBean>>>() }

    fun getArticleList(userId:String,type:Int){
        netWorkJob(
            successResult = {
                val data = mReo.getArticleList(userId,type)
                if (data.isOk()){
                    if (type ==0){
                        normalArticleResponse.value = data
                    }else{
                        secretArticleResponse.value = data
                    }
                }else{
                    toast(data.message)
                }
            }
        )
    }

    fun getSecretStatus(userId: String){
        netWorkJob(
            successResult = {
                val data = mReo.getSecretStatus(userId)
                if (data.isOk()){
                    secretStatusResponse.value = data
                }else{
                    toast(data.message)
                }
            }
        )
    }


    fun setSecret(userId: String,secret:String){
        netWorkJob(
            successResult = {
                val data = mReo.setSecret(userId,secret)
                if (data.isOk()){
                    setSecretResponse.value = data
                }else{
                    toast(data.message)
                }
            }
        )
    }


}